package cn.jk.bean;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * 当类有close或者shutdown方法（public）的时候，会自动被调用，要想阻止被调用就
 * 采用@Bean(destroyMethod = "")
 */
public class MyBean implements InitializingBean,DisposableBean {

	public MyBean(){
		System.out.println("mybean - construct");
	}

	public void init(){
		System.out.println("mybean - init");
	}

	@Override
	public void destroy(){
		System.out.println("mybean - destroy");
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("mybean - afterPropertiesSet");
	}

	@PreDestroy
	public void preDestory(){
		System.out.println("mybean - preDestory");
	}

	@PostConstruct
	public void postConstrauct(){
		System.out.println("mybean - PostConstruct");
	}
}
